package com.kenyi.co.ui.me.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.util.Util;
import com.kenyi.co.GlideApp;
import com.kenyi.co.R;
import com.kenyi.co.ui.me.bean.AvatarListBean;
import com.kenyi.co.utils.ListBaseAdapter;
import com.kenyi.co.utils.LogU;
import com.kenyi.co.utils.SuperViewHolder;

/**
 * Created by Administrator on 2018/1/29.
 */

public class MainAvatarAdapter extends ListBaseAdapter<AvatarListBean> {

    public MainAvatarAdapter(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_me_main_avatar_item;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        AvatarListBean item = mDataList.get(position);
        final ImageView iv_me_main_avatar = holder.getView(R.id.iv_me_main_avatar);
        final ImageView iv_me_main_avatar_select = holder.getView(R.id.iv_me_main_avatar_select);

        try {
            if (Util.isOnMainThread() && mContext != null) {
                GlideApp.with(mContext)
                        .load(item.getAvatarimg())
                        .placeholder(R.drawable.iv_me_avatar)
                        .error(R.drawable.iv_me_avatar)
                        .into(iv_me_main_avatar);
            }

        } catch (Exception e) {

        }

        if (item.getIsselect()) {
            iv_me_main_avatar_select.setVisibility(View.VISIBLE);
        } else {
            iv_me_main_avatar_select.setVisibility(View.INVISIBLE);
        }

    }


}
